package com.foryou.wechat.controller;

import com.foryou.wechat.common.Constants;
import com.foryou.wechat.service.UserImageService;
import com.foryou.wechat.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by Lee.
 */
@RestController
@RequestMapping("/v/image")
public class UserImageController {

    @Autowired
    private UserImageService userImageService;

    @PostMapping("/uploadForWorks")
    public Response uploadForWorks(Long businessId, MultipartFile[] files){
        try {
            return userImageService.uploadForWorks(businessId, files);
        } catch (Exception e) {
            return Response.failure(Constants.OPERATION_FAILURE);
        }
    }

    @PostMapping("/uploadForFiled")
    public Response uploadForFiled(Long businessId, MultipartFile[] files){
        try {
            return userImageService.uploadForFiled(businessId, files);
        } catch (Exception e) {
            return Response.failure(Constants.OPERATION_FAILURE);
        }
    }

    @PostMapping("/uploadForShoot")
    public Response uploadForShoot(Long businessId, MultipartFile[] files){
        try {
            return userImageService.uploadForShoot(businessId, files);
        } catch (Exception e) {
            return Response.failure(Constants.OPERATION_FAILURE);
        }
    }
}
